package game.view.component
{
	import com.greensock.TweenMax;
	import morn.App;
	import flash.display.*;
	import game.util.Util;
	import game.model.type.NoticeCMD;
	import com.base.event.ZooEvent;
	import game.view.base.component.NoticeViewUI;
	public class NoticeView extends NoticeViewUI
	{
		private var htmlList:Array=[];
		private var gunIndex:int=-1;
		public function NoticeView()
		{
			super();
			var maskMc:Sprite=new Sprite;
			maskMc.graphics.beginFill(0xcccccc);
			maskMc.graphics.drawRect(0,0,1000,24);
			maskMc.graphics.endFill();
			this.noticeBox.addChild(maskMc);
			noticeLabel.mask=maskMc;
			this.noticeLabel.y=30;
		}
		override protected function initialize():void
		{
			super.initialize();
			ZooMain.event.addEventListener(NoticeCMD.NOTICE_Notice,setData);
		}
		public function setData(evt:ZooEvent):void{
			trace("NoticeView setData ");
			if(evt.data.content.list.length==0)return;
			htmlList.length=0;
			for(var i:int=0;i<evt.data.content.list.length;i++){
				var dvo:Object=evt.data.content.list[i];
				var name:String=Util.interceptCharacter(dvo.nick,12);
				
				var awname:String=dvo.awardName;
	
				var time:Number=2000;
				var str:String="恭喜    <font color='#FFE360'>"+name+"</font> 获得 <font color='#FFE360'> "+awname+"*"+dvo.amount+" </font>价值<font color='#FFE360'>"+dvo.awardMoney+"呱元</font>";
				
				var vo:Object={str:str,time:time};
				htmlList.push(vo);//awardLevel
				
			}
			if(gunIndex==-1){
				noticeItemGunFun();
			}
		}
		private function noticeItemGunFun():void{
			gunIndex++;
			if(gunIndex>=htmlList.length)gunIndex=0;
			var _this=this;
			var vo:Object=htmlList[gunIndex];
			noticeLabel.text=vo.str;
			noticeLabel.y=30;
			TweenMax.to(noticeLabel,0.5,{y:0,onComplete:function():void{
				
				TweenMax.killTweensOf(noticeLabel);
				App.timer.doOnce(vo.time,function():void{
					TweenMax.to(noticeLabel,0.5,{y:-30,onComplete:function():void{
						_this.noticeItemGunFun();
					}});
				});
			}});
		}
	}
}



